<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Module: ActiveRecord::Userstamp</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Module</strong></td>
          <td class="class-name-in-header">ActiveRecord::Userstamp</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../files/lib/userstamp_rb.html">
                lib/userstamp.rb
                </a>
        <br />
            </td>
        </tr>

        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
Active Records will automatically record the user who created and/or
updated a database objects if fields of the names created_by/created_by are
present.
</p>
<p>
This module requires that your user object (which by default is <tt><a
href="../User.html">User</a></tt> but can be changed using the
<tt>user_model_name</tt> method) contains an accessor called
<tt>current_user</tt> and is set with the instance of the currently logged
in user (typically using a <tt>before_filter</tt> and the session.
</p>
<p>
The functionality can be turned off on a case by case basis by setting the
<tt>record_userstamps</tt> property of your <a
href="../ActiveRecord.html">ActiveRecord</a> object to false.
</p>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000014">create_with_user</a>&nbsp;&nbsp;
      <a href="#M000013">included</a>&nbsp;&nbsp;
      <a href="#M000015">update_with_user</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M000013" class="method-detail">
        <a name="M000013"></a>

        <div class="method-heading">
          <a href="Userstamp.src/M000013.html" target="Code" class="method-signature"
            onclick="popupCode('Userstamp.src/M000013.html');return false;">
          <span class="method-name">included</span><span class="method-args">(base)</span>
          </a>
        </div>
      
        <div class="method-description">
        </div>
      </div>

      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000014" class="method-detail">
        <a name="M000014"></a>

        <div class="method-heading">
          <a href="Userstamp.src/M000014.html" target="Code" class="method-signature"
            onclick="popupCode('Userstamp.src/M000014.html');return false;">
          <span class="method-name">create_with_user</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
This method is an alias for the normal <tt>create</tt> method. This is
where we set the <tt>created_by</tt> and <tt>updated_by</tt> attributes.
This only happens if the attributes exist for the model, the
<tt>record_userstamps</tt> attribute is true, and the user model has the
<tt>current_user</tt> set.
</p>
<p>
After we update those attributes we continue by running the normal
<tt>create</tt> method where the object is actually validated and saved.
</p>
        </div>
      </div>

      <div id="method-M000015" class="method-detail">
        <a name="M000015"></a>

        <div class="method-heading">
          <a href="Userstamp.src/M000015.html" target="Code" class="method-signature"
            onclick="popupCode('Userstamp.src/M000015.html');return false;">
          <span class="method-name">update_with_user</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
This method is an alias for the normal <tt>update</tt> method. This is
where we set the <tt>updated_by</tt> attribute. This only happens if the
attributes exist for the model, the <tt>record_userstamps</tt> attribute is
true, and the user model has the <tt>current_user</tt> set.
</p>
<p>
After we update those attributes we continue by running the normal
<tt>update</tt> method where the object is actually validated and saved.
</p>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>